<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>为指定元素添加子元素</title>
<script>
  function create() {
    var e = document.createElement("input");
    e.type = "text";
    e.value = "text";
    // 添加子元素前须确保调用对象不是由元素组成的数组
    document.getElementById("frm1").appendChild(e);
  }
</script>
</head>
<body onload="create()">
  <form id="frm1"></form>
</body>
</html>